	//点击隐藏
	function no(){
		$('#dom').hide();
		$('#dom_ajax').hide();
		$('#ok8sedit').hide();
		$('#mymodal').hide();
		return false;
	}
	
	//显示文字
	function word(){
		$('#dom').hide();
		var item = $('#select_item').val();
		var offset = $('#'+item).offset();
		var top    = offset.top;
		var height = $('#'+item).height();
		$('#ok8sedit').css('top',top+height+10);
		$('#ok8sedit').show();
		return false;
	}
	
	//显示样式
	function more_style(){
		$('#mymodal').show();
		$('#ok8sedit').hide();
		$('body,html').addClass('ovfHiden');
		return false;
	}
	
	//添加文字
	function add_word(){
		var text  = $('#stxt').text();
		var select_item = $('#select_item').val(); 
		
		var style_size   = $('#text_style_size').val();
		var style_color  = $('#text_style_color').val();
		var style_align  = $('#text_style_align').val();
		var style = '';
		if(style_size != ''){
			style += 'font-size:'+style_size+'px;';
		}
		if(style_color != ''){
			style += 'color:'+style_color+';';
		}
		if(style_size  != ''){
			style += 'text-align:'+style_align+';';
		}
		
		var html = text_html(text,style);
		if(select_item == ''){
			$('#middle_content').append(html);
			//隐藏所有
		}else{
			$('#'+select_item).after(html);
		}
		$('#stxt').text('');
		no();
		return false;
	}
	
	//组装文字html
	function text_html(text,style){
		var count = $('body').find('[id^="ng_"]').length;
		count  = count.length - 1;
		if(count < 0 ){
		   count = 0;
		}
		if(text != ''){
			var html = '';
			html += '<div class="pa2" style="'+style+';word-wrap: break-word;padding:10px 5px" id="ng_'+count+'" data-position="ng_'+count+'" onclick="position(this)">'+text+'</div>';		
		}else{
			return false;
		}
		return html;
	}
	

	//组装文字样式
	function text_style(obj, name, val) {
		
		switch (name) {
		case "text_style_color":
			$(obj).parents('.data-color').find('div[data-color="color"]').css('border-color','#fcf8f8');
			text_style_color = val;
			$("#text_style_color").val(val);
			break;
		case "text_style_size":
			$(obj).parents('.data-size').find('div[data-size="size"]').css('border-color','#fcf8f8');
			text_style_size = val;
			$("#text_style_size").val(val);
			break;
		case "text_style_align":
			$(obj).parents('.data-align').find('div[data-align="align"]').css('border-color','#fcf8f8');
			text_style_align = val;
			$("#text_style_align").val(val);
			break
		}
		$(obj).css('border-color','#3cd09a');
	}
	
	//文字样式确定
	function word_style(){
	
		var style_size   = $('#text_style_size').val();
		var style_color  = $('#text_style_color').val();
		var style_align  = $('#text_style_align').val();
		var style = '';
		if(style_size != ''){
			$('#stxt').css('font-size',''+style_size+'px');
		}
		if(style_color != ''){
		
			$('#stxt').css('color',style_color);
		}
		if(style_size  != ''){
			$('#stxt').css('text-align',style_align);
		}
		$('#ok8sedit').show();
		$('#mymodal').hide();
		$('body,html').removeClass('ovfHiden');
		var item = $('#select_item').val();
		var offset = $('#'+item).offset();
		var height = $('#'+item).height();
		$('body,html').scrollTop(offset.top+height);
		return false;
	}
	
	//清除word
	function empty_word(){
		$('#stxt').html('');
		return false;
	}
	
	//异步删除
	function delete_html(obj){
		var item = $('#select_item').val();
		$('#'+item).remove();
		$('#select_item').val();
		$('#dom').hide();
	}
	
	//删后
	function delete_after(){
		var item = $('#select_item').val();
		$('#'+item).next('[id^="ng_"]').remove();
		$('#select_item').val();
		$('#dom').hide();
	}
	
	//删除前
	function delete_before(){
		var item = $('#select_item').val();
		$('#'+item).prev('[id^="ng_"]').remove();
		$('#select_item').val();
		$('#dom').hide();
	}

	//插入视频
	function ajax_video(){
		$('body,html').addClass('ovfHiden');
		$('#video').show();
		$('#dom').hide();
	}
	
	//确认提交视频
	function commit(){
		var video_url = $("input[name='video_link']").val();
		if(video_url == ''){
			$('body,html').removeClass('ovfHiden');
			$('#video').hide();
			return false;
		}
		//获取dom总数
		var count = $('body').find('[id^="ng_"]').length;
		count  = count + 1;
		
		var html = '<div onclick="position(this)" data-position="ng_'+count+'" id = "ng_'+count+'"  style="padding:15px;display:inline-block;">'+video_url+'</div>';
	    var value = $('#select_item').val();
        $('#'+value).after(html);
		$("input[name='video_link']").val('');
		$('body,html').removeClass('ovfHiden');
		$('#video').hide();
		
		var item = $('#select_item').val();
		var offset = $('#'+item).offset();
		var height = $('#'+item).height();
		
		$('body,html').scrollTop(offset.top+height);
		iframe_control();
		video_adapt();
		return false;
	}
	
	
	
	
//获取当前定位
function position(obj){
		
	var offset = $(obj).offset();
	var top    = offset.top;
	var height = $(obj).height();
	var value  = $(obj).attr('data-position'); 
	
	$('#middle_content').find('.css_background').removeClass('css_background');
	$(obj).addClass('css_background');
	//显示
	$('#dom').css('display','block');
	$('#dom').css('top',top+height+10);
	
	$('#select_item').val(value);
	$('#dom_ajax').show();
	
	$('#mymodal').hide();
	$('#ok8sedit').hide();
	event.stopPropagation(); 
}

//组装html元素0：文字，1：图文，2：视频，3：音乐
function group_type(result,public_url){

	var count = $('body').find('[id^="ng_"]').length;
	count  = count + 1;
	if(result.data.type == '0'){
		var html = '<div style="padding:10px 5px;"  data-position="ng_'+count+'" id = "ng_'+count+'"  onclick="position(this)"><a data-href="'+result.data.url+'">'+result.data.title+'</a></div>';
	}else if(result.data.type == '2'){//href
		var html = '<div onclick="position(this)" data-position="ng_'+count+'" id = "ng_'+count+'"  style="padding: 20px;display:inline-block;">'+result.data.video_url+'</div>';
	}else if(result.data.type == '1'){
		if(result.data.button_type == '1'){
			if(result.data.button_position == '1'){
				var html = '<div style="position:fixed;bottom:-7px;width:100%;max-width:640px;" onclick="position(this)" data-position="ng_'+count+'" id = "ng_'+count+'"><a data-href="'+result.data.url+'"><img src="'+public_url+result.data.thumb+'" style="width:100%;padding:0px;" class="not"></a><img src="'+public_url+'/Public/img/delete.png" class="not" style="float:right;width:24px;position:absolute;right:6px;" onclick="delete_img(this)"></div>';
			}else{
				var html = '<div style="position:fixed;top:0px;width:100%;max-width:640px;" onclick="position(this)" data-position="ng_'+count+'" id = "ng_'+count+'"><a data-href="'+result.data.url+'"><img src="'+public_url+result.data.thumb+'" style="width:100%;padding:0px;" class="not"></a><img src="'+public_url+'/Public/img/delete.png" style="float:right;width:24px;position:absolute;right:6px;" class="not" onclick="delete_img(this)"></div>';
			}
		}else{
			var html = '<div style="padding:10px 5px;" onclick="position(this)" data-position="ng_'+count+'" id = "ng_'+count+'"><img src="'+public_url+result.data.thumb+'" class="not"><a data-href="'+result.data.url+'">'+result.data.title+'</a></div>';
		}
	}else if(result.data.type == '3'){
		var html ="<audio src='"+result.video_url+"' autoplay='autoplay' loop='loop'></audio>";
	}
	return html;
}


//删除图片
function delete_img(obj){
	$(obj).parent().remove();
	event.stopPropagation(); 
	return false;
}

//显示
function success_show(){
	$('#banner').show();
	$('body,html').addClass('ovfHiden');
	$('#new_title').focus();
	return false;
}

//取消
function show_no(){
	$('#banner').hide();
	/* $('#new_title').val(''); */
	$('body,html').removeClass('ovfHiden');
	return false;
}


 //插入音乐
function insertion_mc(obj){
	if($("#music").length>0){
		$('#music').remove();
	}
	var tid = $(obj).attr('data-tid');
	var url = $(obj).attr('url');
	
	var html ='<div id="music"  data-tid="'+tid+'"><audio src="'+url+'" autoplay="autoplay" loop="loop"></audio></div>';
	$('body,html').removeClass("scrool");
	var value = $('#select_item').val();
	$('#'+value).before(html);
	$('#dom').css('display','none'); 
	$(obj).parents('#page4').remove();  
}
	
	//取消
	function item_no(){
		$('#dom').hide();
	}
	
	//模板列表取消
	function delete_ad(obj){
		$('body,html').removeClass("scrool");
		$(obj).parents('#page4').remove();
	}
	
	//点击效果
	function ajax_click(){
		$('#file').click();
	}
	